Skip to content

feat(toolchains): discover JDKs on fixed Windows drives - #52

Merged
1lck merged 2 commits into
mainfrom
devin/1796097842-windows-jdk-provider
Dec 1, 2026
Merged

1lck merged 2 commits into
mainfrom
devin/1796097842-windows-jdk-provider

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Windows 用户把 JDK 安装到非系统盘的常见目录(例如 D:\Program Files\Java\jdk1.8.0_151)时,现有声明式扫描只看 C:\Program Files,导致该 JDK 不进选择器。本 PR 在 Java 插件后端新增 toolchainProviders 版本 0 的 installs 提供方:在 Windows 枚举 fixed drives,对各盘 Program Files 下与现有定义一致的 Java、Eclipse Adoptium、Microsoft、Zulu、Amazon Corretto、BellSoft 安装根做有界扫描,从 release 的 JAVA_VERSION 读取版本并返回安装与扫描根 watch 路径。扫描只读元数据,不执行任何被发现的 Java 程序;工作区内的路径不会被报告为系统安装。

插件仍使用最低可用能力版本:backend: 0、toolchainProviders: 0。新增权限只有 toolchains.provide(配合已有 backend.launch),用途是回答 JDK 安装位置查询;契约、SDK 与端到端宿主基线统一提升到 Lithe Desktop desktop-v0.8.22 使用的 Core a1a792a5a3b2284720d3209b7a9c93394c365c18 / host b62a0817d321fe4a76dfabd3d54990a65324d3c5。

日志与输出边界:后端使用官方 Rust SDK;提供商不写 stdout/stderr、不记录路径或 release 文件内容,缺失目录按预期缺失处理,取消通过 Cancellation 结束查询,扫描结果数和每个 release 文件读取量均有上限。功能矩阵已新增本能力;无 UI 变更,因此没有新增截图。

Verification

  • cargo fmt --all --check
  • cargo clippy --workspace --all-targets --locked -- -D warnings
  • cargo test --workspace --locked(全部通过)
  • node --test --test-timeout=60000 scripts/package/*.test.mjs
  • node --test --test-timeout=15000 scripts/compiler/process.test.mjs
  • scripts/verify-sdk-lock.sh --download / pinned schema validation(Core a1a792a5a3b2284720d3209b7a9c93394c365c18)
  • Windows GetDriveTypeW API 使用按 x86_64-pc-windows-msvc 做了最小编译核对;完整 Windows 后端测试由本 PR 的 Windows CI 执行

未做真实 Windows 桌面端手工验收;功能矩阵保持 implemented / pending,没有声称原生端到端已验证。

Link to Devin session: https://app.devin.ai/sessions/4c017f8b5c4248b4bbabcad166be2672
Open in Devin Desktop: https://app.devin.ai/desktop/session/4c017f8b5c4248b4bbabcad166be2672?variant=devin
Requested by: @1lck


🟢 Devin Review found nothing to fix · View findings · Follow Devin's work

Devin Review

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration
devin-ai-integration Bot marked this pull request as ready for review December 1, 2026 04:29

@devin-ai-integration devin-ai-integration Bot left a comment •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

Newer findings are available below. Devin Review posted a newer report on this PR, in addition to the findings presented here.

Devin Review found 2 findings. Devin was interrupted while fixing; 2 findings are left for you to triage below.

View findings in Devin Review · Follow Devin's work

Devin Review

Comment on lines +82 to +85
let workspace_root = workspace.map(|workspace| {
let root = PathBuf::from(&workspace.root);
dunce::canonicalize(&root).unwrap_or(root)
});

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Open workspace blocks toolchain settings

When an open workspace contains a scanned JDK, scan_drives still reports it to the global picker. The global query omits workspace, but the host passes all open roots to Core’s reply decoder. Core rejects the entire reply, so Toolchains settings fail to load.

Learn more

The provider sees only the optional workspace in its query, and global queries have none. The pinned desktop host’s settingsToolchains.LoadScope calls ToolchainOptions, which supplies all open roots even for global scope. ProviderClient.capture passes those roots to Core’s decodeReply. Core rejects the entire reply when checked_installation_detail finds an installation under any of those roots, and prepareTool propagates the error instead of loading the other toolchains. The same mismatch applies to project queries when the installation is under a different open root.

Example: Open D:\ as a workspace on a machine with D:\Program Files\Java\jdk-21. Then open global Toolchains settings. The provider includes that JDK because its query has no workspace, and Core rejects the reply instead of leaving that JDK out and listing the others.

Recommended fix: Make the host exclude installations under every open workspace root before decoding the provider reply, or extend the query contract to give the provider those roots. Keep Core’s containment check as a backstop. Cover global discovery with an open root and a reply containing both an in-root JDK and an unrelated valid JDK.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +137 to +143
let home = entry.path();
if !home.is_dir() || !java_executable(&home).is_file() {
continue;
}
let Some(version) = release_version(&home) else {
continue;
};

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Standalone runtimes offered as project JDKs

scan_vendor_root accepts a standalone Zulu JRE on a secondary drive because it has java.exe and release metadata. The JDK tool exports the selected runtime as JAVA_HOME, leaving builds that need a JDK without a compiler.

Learn more

The provider scans the Zulu vendor directory without a JDK-name filter, and standalone Azul Windows JRE archives ship both bin/java.exe and a release file with JAVA_VERSION. They do not ship bin/javac.exe. The Java executable layout checks only the launcher, so a host version probe cannot distinguish this runtime from a full JDK.

Example: Extract the Windows Zulu 17 JRE archive under D:\Program Files\Zulu and select it from the JDK picker. The resulting JAVA_HOME points to an installation that can run Java but cannot supply javac to a build.

Recommended fix: Require bin/javac.exe as well as bin/java.exe before offering a Windows installation from this provider. Add a scan test with both a standalone JRE and a full JDK so the picker receives only the latter.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

@1lck
1lck merged commit 0cfb584 into main Dec 1, 2026
4 of 7 checks passed
@1lck
1lck deleted the devin/1796097842-windows-jdk-provider branch December 1, 2026 07:44

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@1lck 1lck mentioned this pull request Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant